﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin_panel/Admin.master" AutoEventWireup="true" CodeFile="BanTin.aspx.cs" Inherits="Admin_BaiViet" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
     <title>Quản lý bản tin</title>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <style type="text/css">
         .x_handle {
             color: blue;
             cursor: pointer;
         }
     </style>
 
    <script type="text/javascript">

        function kiemtranhaprong(field) {
            var str = field.value.toLowerCase();
            if (str == "") {
                alert("vui lòng nhập vào tiêu đề bài viết");
                this.focus();
                return false;
            }

        }

    </script>

    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">

            <h3>
                <img src="images/icons/pencil_48.png" width="16" height="16" />Quản lý bản tin </h3>

            <ul class="content-box-tabs">
                <li><a href="#tab1" class="default-tab">Danh sách bản tin</a></li>
                <!-- href must be unique and match the id of target div -->
                <li><a href="#tab2">Thêm bản tin mới</a></li>
            </ul>

            <div class="clear"></div>

        </div>
        <!-- End .content-box-header -->

        <div class="content-box-content">

            <!-- Begin #tab1_danh sach ban tin-->
            <div class="tab-content default-tab" id="tab1">
                <!-- This is the target div. id must match the href of this div's tab -->
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>

                        <asp:GridView ID="_grid_bantin" runat="server" AutoGenerateColumns="False"
                            EnableModelValidation="True" AllowPaging="True"
                            OnPageIndexChanging="_grid_bantin_PageIndexChanging" BackColor="White"
                            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px"  EnableSortingAndPagingCallbacks="True"
                            HorizontalAlign="Center" OnRowDeleting="_grid_bantin_RowDeleting"
                            DataKeyNames="IDTin" Width="100%">
                            <Columns>
                                <asp:TemplateField HeaderText="Select">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkBxSelect" runat="server" />
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                                    <HeaderTemplate>
                                        <asp:CheckBox ID="chkBxHeader" onclick="javascript:HeaderClick(this);" runat="server" />
                                    </HeaderTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="IDTin" HeaderText="Mã Tin">
                                    <ControlStyle Width="0px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="NgayDang" HeaderText="Ngày đăng" ReadOnly="True" SortExpression="NgayDang" DataFormatString="{0:d}" />
                                <asp:BoundField DataField="TieuDe" HeaderText="Tiêu đề" />
                                <asp:TemplateField HeaderText="Loại tin"></asp:TemplateField>
                                <asp:TemplateField HeaderImageUrl="~/Admin_panel/images/icons/Actions-document-edit-icon (1).png" HeaderText="Sửa">
                                    <ItemTemplate>
                                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("IDTin", "Suabaiviet.aspx?idbt={0}") %>' Text="Sửa"></asp:HyperLink>
                                    </ItemTemplate>
                                    <ControlStyle Width="20px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderImageUrl="~/Admin_panel/images/icons/edit-delete-icon.png" HeaderText="Xóa ">

                                    <ItemTemplate>
                                        <asp:Button ID="btnXoaDanhMuc" CssClass="x_handle" runat="server" CommandName="Delete" Text="Xóa"
                                            OnClientClick="return confirm('Bạn muốn xóa bản tin này?(Y/N)');" BorderStyle="None" Font-Bold="True" ForeColor="#68A925" BackColor="#FFF7E7" />
                                    </ItemTemplate>
                                </asp:TemplateField>


                            </Columns>
                            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                            <PagerSettings Position="TopAndBottom" />
                            <PagerStyle BorderStyle="Solid" ForeColor="#003399" HorizontalAlign="Left" VerticalAlign="Middle" Width="120px" Wrap="True" BackColor="#99CCCC" />
                            <RowStyle BackColor="White" ForeColor="#003399" />
                            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                        </asp:GridView>



                        <table>
                            <tfoot>
                                <tr>
                                    <td colspan="6">
                                        <div class="bulk-actions align-left">
                                            <asp:Button OnClientClick="return confirm('Bạn chắc chắn muốn xóa những mục đã chọn?(Y/N)');" class="button" ID="btn_xoa" OnClick="btn_xoa_Click" runat="server" Text="Xóa mục đã chọn" />
                                        </div>
                                        <div class="clear"></div>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <!-- End #tab1_Danh sach ban tin -->
            <!--begin #tab2_them ban tin-->
            <div class="tab-content " id="tab2">




                <fieldset>
                    <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->

                    <p>
                        <label>
                            Tiêu đề bản tin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                        </label>
                        <asp:TextBox ID="txtbantin" class="text-input medium-input" runat="server"></asp:TextBox>
                        <br />
                    </p>
                    <p>
                        <label>
                            Nội dung tóm tắt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                        </label>
                        <asp:TextBox ID="txtnoidungtomtat" class="text-input " runat="server"
                            Height="82px" TextMode="MultiLine" Width="500px" Font-Size="Small"></asp:TextBox>
                        <br />
                        <small>Nhập vào nội dung tóm tắt của bản tin,giới hạn trong độ dài khoảng 200 chữ</small>
                    </p>

                    <label>Nội dung bản tin</label>


                    <FCKeditorV2:FCKeditor ID="FCK_bantin" runat="server"></FCKeditorV2:FCKeditor>


                    <p></p>
                    <p>
                        <asp:Button class="button" ID="btnDangBT" OnClick="btnDangBT_Click" OnClientClick="kiemtranhaprong(this);" runat="server" Text="Đăng bài" />
                        <asp:Button class="button" ID="btnHuyBT" runat="server" Text="Hủy" />
                    </p>


                </fieldset>
                <div class="clear"></div>
                <!-- End .clear -->
            </div>
            <!-- End #tab2_them ban tin  -->


        </div>
        <!-- End .content-box-content -->
    </div>
    <script type="text/javascript">
        var TotalChkBx;
        var Counter;

        window.onload = function () {
            //SỐ LƯỢNG CHECKBOX TRONG GRIDVIEW
            TotalChkBx = parseInt('<%= this._grid_bantin.Rows.Count %>');

            //SỐ LƯỢNG CHECKBOX ĐƯỢC CHECKED
            Counter = 0;
        }

        function HeaderClick(CheckBox) {
            //Get target base & child control.
            var TargetBaseControl =
                document.getElementById('<%= this._grid_bantin.ClientID %>');
             var TargetChildControl = "chkBxSelect";

             //Get all the control of the type INPUT in the base control.
             var Inputs = TargetBaseControl.getElementsByTagName("input");

             //Checked/Unchecked all the checkBoxes in side the GridView.
             for (var n = 0; n < Inputs.length; ++n)
                 if (Inputs[n].type == 'checkbox' &&
                           Inputs[n].id.indexOf(TargetChildControl, 0) >= 0)
                     Inputs[n].checked = CheckBox.checked;

             //Reset Counter
             Counter = CheckBox.checked ? TotalChkBx : 0;
         }

         function ChildClick(CheckBox, HCheckBox) {
             //get target control.
             var HeaderCheckBox = document.getElementById(HCheckBox);

             //Modifiy Counter; 
             if (CheckBox.checked && Counter < TotalChkBx)
                 Counter++;
             else if (Counter > 0)
                 Counter--;

             //Change state of the header CheckBox.
             if (Counter < TotalChkBx)
                 HeaderCheckBox.checked = false;
             else if (Counter == TotalChkBx)
                 HeaderCheckBox.checked = true;
         }
    </script>
   <script type="text/javascript">
     
        function show() {

            div_left.style.display = "Block";
            div_right.style.display = "Block";
        }
        function hide() {

            div_left.style.display = "None";
            div_right.style.display = "None";
        }





    </script>



</asp:Content>

